package com.ymatou.iapi.godmch.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getSupplierPicBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createSupplierCodeCall;
import com.ymatou.iapi.godmch.service.getSupplierPicCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*获取邀请供货商分享图片
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getSupplierPic{
	private static getSupplierPicBean bean;
	private static getSupplierPicCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取邀请供货商分享图片");
	}

	@Before
	public void caseUp() {
		bean=new getSupplierPicBean();
		call=new getSupplierPicCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierPic_001() {
		Logger.start(true,"获取邀请供货商分享图片-验证商户是独立商户的供货商");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            GodmchManageCallService.initRegisterByCode(mchId, createSupplierCodeCall.getCode());
            
            bean.setMchId(mchId); 
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");
			Logger.verifyEquals(createSupplierCodeCall.getCode(), call.getCode(), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierPic_002() {
		Logger.start(true,"获取邀请供货商分享图片-验证商户是独立商户");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("", call.getPicUrl(), "验证PicUrl");
			Logger.verifyEquals("", call.getCode(), "验证Code");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierPic_003() {
		Logger.start(true,"获取邀请供货商分享图片-验证商户是平台渠道");
		try {
			
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			editmchBean editmchBean=GodmchManageCallService.IniteditmachBean(createmchBean.getMchId());
			GodmchManageCallService.editmachCall(editmchBean);
			
			bean.setMchId(createmchBean.getMchId());
			call.setData(bean);
			call.callService();			
			
//			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");
//			Logger.verifyEquals("未创建供货商邀请码", call.getMessage(), "验证Message");
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("", call.getPicUrl(), "验证PicUrl");
			Logger.verifyEquals("", call.getCode(), "验证Code");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierPic_004() {
		Logger.start(true,"获取邀请供货商分享图片-验证商户Id不存在");
		try {
			
			bean.setMchId(99999);
			call.setData(bean);
			call.callService();			
			
//			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");
//			Logger.verifyEquals("商户不存在", call.getMessage(), "验证Message");
			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("", call.getPicUrl(), "验证PicUrl");
			Logger.verifyEquals("", call.getCode(), "验证Code");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierPic_005() {
		Logger.start(true,"获取邀请供货商分享图片-验证商户Id为空");
		try {
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}